<?php

namespace app\controller;

use app\model\Cos;
use app\model\Card;
use app\model\Fish;
use app\model\Ornament;
use app\model\Skin;
use app\model\Staff;
use support\Response;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;

//图鉴控制器
class DexController extends Base
{

    /**
     * @throws ModelNotFoundException
     * @throws DbException
     * @throws DataNotFoundException
     */
    public function list(): Response
    {
        $type = $this->request->get('type');


        switch ($type) {
            case DEX_TYPE['角色']:
                $res = (new Staff())->select();
                break;
            case DEX_TYPE['卡牌']:
                $res = (new Card())->select();
                break;
            case DEX_TYPE['服装']:
                $res = (new Skin())->select();
                break;
            case DEX_TYPE['鱼类']:
                $res = (new Fish())->select();
                break;
            case DEX_TYPE['建筑装饰品']:
                $res = (new Ornament())->select();
                break;
            default:
                return $this->fail('类型错误');
        }


        return $this->success('ok', $res->toArray());
    }


}